package com.gxa.controller.commserve;

import com.gxa.common.utils.Result;
import com.gxa.entity.commserve.RomplaintRecord;
import com.gxa.service.commserve.RomplaintRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjl
 * @since 2022-10-12 11:18:01
 */
@Api(tags = "投诉记录")
@RestController
@RequestMapping("/romplaint-record")
public class RomplaintRecordController {
    @Autowired
    private RomplaintRecordService romplaintRecordService;


//    Date date = new Date("2022/10/11");
//    List<Object> romplaintRecordList= new ArrayList<>();
//    ComplaintsSuggestions complaintsSuggestions = new ComplaintsSuggestions(1,"卫生投诉","第三方的规划法规和地方更丰富",date,0,"张三","12345678910",0);
//    public RomplaintRecordController(){this.init();}
//    void init(){
//        RomplaintRecord romplaintRecord = new RomplaintRecord(1,"卫生不好","王五",date,this.complaintsSuggestions,0);
//        romplaintRecordList.add(romplaintRecord);
//        RomplaintRecord romplaintRecord1 = new RomplaintRecord(2,"卫生不好","王五",date,this.complaintsSuggestions,0);
//        romplaintRecordList.add(romplaintRecord1);
//    }

    @CrossOrigin(origins = "*",maxAge = 3600)//跨域请求配置
    @ApiOperation(value = "查询投诉记录")
    @GetMapping("list/{id}")
    public Result list(@PathVariable("id") Integer id){
        try {
            List<RomplaintRecord> romplaintRecordList = this.romplaintRecordService.queryList(id);
            Result<List<RomplaintRecord>> result = Result.success(romplaintRecordList);
            return result;
        }catch (Exception e){
            e.printStackTrace();
            return Result.failed("查询失败");
        }
    }



}
